	<!-- 顶部功能按钮 	
	<div style="margin-bottom:10px;float:left;">
		{volist name="$tab_ext.top_button" id="rs"}
		 {if $rs.type=='add'}
			<a href="{$rs.href|default=auto_url('add')}" class="layui-btn layui-btn-primary {$rs.class}"><li class="{$rs.icon|default='fa fa-plus'}"></li> {$rs.title|default='新增'}</a>
		 {elseif($rs.type=='delete') /}
			<a href="{:auto_url('delete')}" onclick="return delete_all($(this));" class="layui-btn layui-btn-primary {$rs.class}"><li class="{$rs.icon|default='fa fa-fw fa-remove'}"></li> {$rs.title|default='批量删除'}</a>
		 
		 {else /}
			<a href="{$rs.href}" class="layui-btn layui-btn-primary {$rs.class}" target="{$rs.target}" data-ids="{$rs['target-form']}"><li class="{$rs.icon|default='fa fa-external-link-square'}"></li> {$rs.title}</a>
		 {/if}	
		{/volist}
	</div>
	-->
	
	<!-- 字段搜索功能 
	<div style="margin-bottom:10px;float:right;">
		<select name="search_field">
		<option value="" selected>选择字段</option> 
		{notempty name="$tab_ext.id"}<option value="{$tab_ext.id}">{$tab_ext.id}</option>{else /}<option value="id">ID</option>{/notempty}
		{volist name="$tab_ext.search" id="name"}
			<option value="{$key}">{$name}</option> 
		{/volist}
		</select>
		<input type="text" placeholder='请输入关键字' name="search_word" style="line-height:23px;width:150px;"> <input onclick="search_content()" type="button" name="" value="搜索" class="layui-btn layui-btn-sm">
	</div>
	-->



    <table class="ListTable" style="clear:both;width:100%">
	<tr>
	<th width="7%">
	   <input type="checkbox" name="" onclick="choosebox($(this))">			
			{php}$_id=$tab_ext['id']?:'id';{/php}
			{:strtoupper($_id)}
			{if input('_order')==$_id&&input('_by')=='desc'}
				<a href="{:fun('Field@make_admin_filter_url',$_id,'asc',input('search_field'),input('keyword'))}"><i style="color:red;" class="glyphicon glyphicon-triangle-bottom"></i></a>
			{elseif input('_order')==$_id&&input('_by')=='asc'}
				<a href="{:fun('Field@make_admin_filter_url',$_id,'desc',input('search_field'),input('keyword'))}"><i style="color:red;" class="glyphicon glyphicon-triangle-top"></i></a>
			{else /}
				<a href="{:fun('Field@make_admin_filter_url',$_id,'asc',input('search_field'),input('keyword'))}"><i class="fa fa-unsorted"></i></a>
			{/if}			
	</th>
	<!-- 自定义字段头部标题 -->
	{volist name=":fun('field@fields_to_table',$f_array,[])" id="vs"}
    <th data-status="{$rs.status}" data-id="{$rs.id}">
		<!--排序-->
		{if in_array($vs.name,explode(',',$tab_ext.order))}
			{if input('_order')==$vs.name&&input('_by')=='desc'}
				<a href="{:fun('Field@make_admin_filter_url',$vs.name,'asc',input('search_field'),input('keyword'))}"><i style="color:red;" class="glyphicon glyphicon-triangle-bottom"></i></a>
			{elseif input('_order')==$vs.name&&input('_by')=='asc'}
				<a href="{:fun('Field@make_admin_filter_url',$vs.name,'desc',input('search_field'),input('keyword'))}"><i style="color:red;" class="glyphicon glyphicon-triangle-top"></i></a>
			{else /}
				<a href="{:fun('Field@make_admin_filter_url',$vs.name,'desc',input('search_field'),input('keyword'))}"><i class="fa fa-unsorted"></i></a>
			{/if}			
		{/if}
		<!--筛选项-->
		{if $tab_ext['filter_search'][$vs['name']]}
			<i {if input('search_field')==$vs.name}style="color:red;"{/if} class="fa fa-filter" onclick="layer.tips('<a href=\'{:fun('Field@make_admin_filter_url',input('_order'),input('_by'))}\' style=\'color:#fff;\'>不限</a><br>{volist name="$tab_ext['filter_search'][$vs['name']]" id="name"}<a style=\'{if input('keyword')==$key}color:red;{else /}color:#fff;{/if}\' href=\'{:fun('Field@make_admin_filter_url',input('_order'),input('_by'),$vs.name,$key)}\'>{$name}</a><br>{/volist}', $(this), {tips: [3, '#0FA6D8'],tipsMore: false,time:5000 });"></i>
		{/if}
	  {$vs.title} 
	</th>
	{/volist}
	
	<!-- 更多菜单头部标题 -->
	{volist name=":fun('field@get_rbtn',$tab_ext['right_button'],[])" id="vs"}
      <th>{$vs.title}</th>
	{/volist}
	
	<!-- 没有特别指定按钮时,就显示默认的修改与删除 -->
	{if !isset($tab_ext.right_button)}
      <th width="6%">删除</th>
      <th width="6%">修改</th> 
	{/if}

    </tr>

	<!-- 列表内容部分开始 -->
{volist name="listdb" id="rs"}
{php}$tab_ext['id'] && $rs['id']=$rs[$tab_ext['id']];{/php}
    <tr bgcolor="#FFFFFF" class="trA" onmouseover="this.className='trB'" onmouseout="this.className='trA'"> 
      <td><input type="checkbox" name="ids[]" value="{$rs.id}"> {$rs.id}</td>
	 <!-- 自定义字段数据列表 -->
	{volist name=":fun('field@fields_to_table',$f_array,$rs)" id="vs"}
      <td class="{eq name='i' value='1'}Left{/eq}">{$vs.value}</td>
	{/volist}
    
	<!-- 更多菜单数据列 -->
	{volist name=":fun('field@get_rbtn',$tab_ext['right_button'],$rs)" id="vs"}
      <td>{$vs.value}</td>
	{/volist}
	
	<!-- 没有特别指定按钮时,就显示默认的修改与删除 -->
	{if !isset($tab_ext.right_button)}
      <td><a href="{:auto_url('delete','ids='.$rs.id)}" class="_dels" onclick="return confirm('你确实要删除吗?不可恢复,请慎重!')" title="删除"><i class="fa fa-fw fa-remove"></i></a></td>
	  <td><a href="{:auto_url('edit','id='.$rs.id)}" title="修改"><i class="fa fa-fw fa-edit"></i></td>
	{/if}

    </tr>
{/volist}
  </table>

<script type="text/javascript">
var quickedit_url = "{:auto_url('quickedit')}"; //快速编辑的地址

//搜索内容
function search_content(){
	var field = $("select[name='search_field']").val();
	var keyword = $("input[name='search_word']").val();
	if(field==''){
		layer.alert('请选择搜索字段类型');
		return ;
	}else if(keyword==''){
		layer.alert('关键字不能为空');
		return ;
	}
	var url = location.href.indexOf('?')>0 ? location.href.substr(0,location.href.indexOf('?')) : location.href;
	url +='?search_field=' + field + '&keyword=' +keyword;
	window.location.href = url;
}

//全选
function choosebox(that){
	$("input[name='ids[]']").each(function(){
		$(this).prop("checked",that.is(':checked')?true:false);
	});
}

//批量删除
function delete_all(that){
	var ids = [];
	$("input[name='ids[]']").each(function(){
		if( $(this).is(':checked')==true){
			ids.push($(this).val());
		}
	});
	if(ids.length==0){
		layer.alert('你必须选择一项!');
		return false;
	}
	layer.confirm('你要删除吗,不可恢复?',function(){
		var url = that.attr('href');
		$.post(url,{'ids':ids},function(res){
			if(res.code==0){
				layer.closeAll();
				layer.msg('删除成功');
				setTimeout(function(){
					window.location.reload();
				},500);
			}else{
				layer.alert('删除失败,详情如下:'+res.msg);
			}
		}).fail(function (res) {
			layer.alert('系统故障,删除失败!!');
		});

	});
	return false;
}

//快速编辑
function quick_edit(that){
	if(that.val()==that.data('value')){
		//layer.msg('你并没有修改');
		return ;
	}
	layer.load(1);
	$.post(quickedit_url,{
		'pk':that.data('id'),
		'name':that.data('name'),
		'value':that.val(),
	},function(res){
		layer.closeAll();
		if(res.code==0){			
			layer.msg('修改成功');
			setTimeout(function(){
				//window.location.reload();
			},500);
		}else{
			layer.alert('修改失败:'+res.msg);
		}
	}).fail(function (res) {
		layer.closeAll();
		layer.alert('系统故障,删除失败!!');
	});
}


function choose_ids(name){
	var ids = [];
	$("input[name='ids[]']").each(function(){
		if( $(this).is(':checked')==true){
			ids.push($(this).val());
		}
	});
	if(ids.length==0){
		layer.alert('你必须要选择一项!');
		return false;
	}
	str = '';
	ids.forEach(function(v){
		str += name + '[]=' + v + '&';
	});
	return str;
}

//快速更换状态
function change_status(){
	$("._switch").click(function(){
		var that = $(this);
		var value = that.data('value');	
		if(value==1){
			value=0;
		}else{			
			value=1;
		}
		that.data('value',value);
		layer.load(1);
		$.post(quickedit_url,{
			'pk':that.data('id'),
			'name':that.data('name'),
			'value':value,
		},function(res){
			layer.closeAll();
			if(res.code==0){				
				layer.msg('修改成功');
				if(value==0){
					that.css("color","#666666");
					that.removeClass('fa-check-circle');
					that.addClass('fa-ban');
				}else{
					that.css("color","green");
					that.removeClass('fa-ban');
					that.addClass('fa-check-circle');
				}
			}else{
				layer.alert('修改失败:'+res.msg);
			}
		}).fail(function (res) {
			layer.closeAll();
			layer.alert('系统故障,删除失败!!');
		});
	});
}


jQuery(document).ready(function() {
	$(".quick_edit").blur(function(){
		quick_edit($(this))
	});
	$('select.select_edit').change(function(){
		quick_edit($(this));
	});
	
	//其它批量操作
	$("a[data-ids]").click(function(){
		var ids = $(this).data('ids');
		if(ids!=''){
			var str = choose_ids( ids );
			if(str!==false){
				window.location.href = $(this).attr('href') + '?' + str;
			}
			return false;
		}
		
	});
	
	change_status();
});

</script>